package com.lxy.demo.utils;

import com.lxy.demo.dao.ToursInfoDao;
import com.lxy.demo.entity.ToursInfo;

import java.util.ArrayList;
import java.util.List;

public class PageBean {
    //每页显示多少条记录
    private Integer pageSize;
    //一共有多少条记录
    private Integer pageTotal;
    //一共有多少页
    private Integer pageCount;
    //当前第几页
    private Integer p;
    //封装（当前页面）的数据
    private List<ToursInfo> dataList;

    //空构造
    public PageBean() {
        //设置默认值
        pageSize = 3;
        //初始化创建数据对象
        dataList = new ArrayList<>();
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getPageTotal() {
        return pageTotal;
    }

    //设置总共有多少条记录，同时计算出pageCount一共有多少页
    public void setPageTotal(Integer pageTotal) {
        this.pageTotal = pageTotal;
        if (pageTotal % pageSize == 0) {
            pageCount = pageTotal / pageSize;
        } else {
            pageCount = pageTotal / pageSize + 1;
        }
    }

    public Integer getPageCount() {
        return pageCount;
    }

    public Integer getP() {
        return p;
    }

    public void setP(Integer p) {
        if (p < 1) {
            p = 1;
        } else if (p > pageCount) {
            p = pageCount;
        }
        this.p = p;
    }

    public List<ToursInfo> getDataList() {
        return dataList;
    }

    public void setDataList(List<ToursInfo> dataList) {
        this.dataList = dataList;
    }
}
